#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    string getHint(string secret, string guess) {
        unordered_map<int, int> hash;
        for (auto& e : secret)   hash[e]++;

        int Bulls = 0, Cows = 0;
        for (int i = 0; i < secret.size(); ++i)
        {
            if (secret[i] == guess[i] && hash[guess[i]] > 0)
            {
                Bulls++;
                hash[guess[i]]--;
            }
        }
        for (int i = 0; i < secret.size(); ++i)
        {
            if (secret[i] != guess[i] && hash.count(guess[i]) && hash[guess[i]] > 0)
            {
                Cows++;
                hash[guess[i]]--;
            }
        }

        return to_string(Bulls) + "A" + to_string(Cows) + "B";
    }
};